package com.fantabest.common.client;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;

public class ColumnModelManager {

	private FantaBestConstants constants = Registry.get(RegistryKeys.CONSTANTS);
	
	private static ColumnModelManager instance = null;
	
	public static ColumnModelManager getInstance() {
		if(instance == null)	{
			instance = new ColumnModelManager();
		}
		return instance;
	}
	
	public ColumnModel getPlayersCM()	{
		List<ColumnConfig> columns;
		columns = new ArrayList<ColumnConfig>();
		columns.add(new ColumnConfig("lastname", constants.lastname(), 200));
		columns.add(new ColumnConfig("position", constants.position(), 70));
		columns.add(new ColumnConfig("quotation", constants.quotation(), 70));
		columns.add(new ColumnConfig("cost", constants.cost(), 70));
		columns.add(new ColumnConfig("club", constants.club(), 100));
		return new ColumnModel(columns);
	}
	
	public ColumnModel getEditablePlayersCM()	{
		List<ColumnConfig> columns;
		columns = new ArrayList<ColumnConfig>();
		columns.add(new ColumnConfig("lastname", constants.lastname(), 200));
		columns.add(new ColumnConfig("position", constants.position(), 70));
//		columns.add(new ColumnConfig("quotation", constants.quotation(), 70));
		ColumnConfig column = new ColumnConfig("cost", constants.cost(), 70);
		column.setEditor(new CellEditor(new NumberField()));
		columns.add(column);
//		columns.add(new ColumnConfig("club", constants.club(), 100));
		return new ColumnModel(columns);
	}
	
}
